#!/bin/bash

cd /opt/src/php-7.4.16

FREETYPE="/opt/freetype"

FREETYPE2_CFLAGS="-I$FREETYPE/include/freetype2" \
FREETYPE2_LIBS="-L$FREETYPE/lib -lfreetype -Wl,--rpath=$FREETYPE/lib" \
ENCHANT_LIBS="-L/opt/enchant/lib -lenchant-2 -Wl,--rpath=/opt/enchant/lib" \
ENCHANT_CFLAGS=-I/opt/enchant/include/enchant-2 \
GDLIB_CFLAGS="-I/opt/libgd/include" \
GDLIB_LIBS="-L/opt/libjpeg/lib  -ljpeg -L/opt/libtiff/lib  -ltiff -L/opt/libwebp/lib  -lwebp -lgd -L/opt/libgd/lib -Wl,--rpath=/opt/libgd/lib" \
SASL_LIBS="-lgsasl -L/opt/libgsasl/lib -Wl,--rpath=/opt/libgsasl/lib" \
SASL_CFLAGS="-I/opt/libgsasl/include" \
CPPFLAGS="-I/opt/gmp/include -I/opt/readline/include" \
CFLAGS="-I/opt/gmp/include -I/opt/readline/include" \
LDFLAGS="-Wl,--rpath=/opt/readline/lib -Wl,--rpath=$FREETYPE/lib -Wl,--rpath=/opt/enchant/lib -Wl,--rpath=/opt/libgd/lib -L/opt/gmp/lib -Wl,--rpath=/opt/gmp/lib -Wl,--rpath=/opt/libgsasl/lib" \
PKG_CONFIG_PATH="/opt/readline/lib/pkgconfig/:/opt/postgresql/lib/pkgconfig/:/opt/oniguruma/lib/pkgconfig/:/opt/libgsasl/lib/pkgconfig/:/opt/gsasl/lib/pkgconfig/:/opt/libgd/lib/pkgconfig/:/opt/enchant/lib/pkgconfig/:/opt/curl/lib/pkgconfig/:/opt/sqlite3/lib/pkgconfig/:/opt/openssl/lib/pkgconfig/:/opt/libxml2/lib/pkgconfig/" \
PATH="/opt/postgresql/bin:$PATH" \
./configure --prefix=/opt/php7.4.16 --enable-fpm --enable-gd --with-external-gd \
--with-jpeg --with-webp --with-xpm --with-freetype --enable-bcmath --with-zlib \
--with-pcre-jit --enable-sockets --enable-soap --with-pdo-mysql --with-mysql-sock \
--with-mysqli --enable-mysqlnd --with-openssl --with-zip --enable-mbstring \
--enable-intl --enable-pcntl --with-bz2=/opt/bzip2 \
--enable-calendar --enable-sysvmsg \
--enable-sysvsem --enable-sysvshm --with-curl --enable-ftp --with-enchant \
--enable-exif --with-gmp --with-gettext --with-sodium --enable-dba \
--with-pspell=/opt/aspell \
--with-readline=/opt/readline --with-snmp --with-xsl --enable-shmop \
--with-xmlrpc \
--with-tidy=/opt/tidy --with-pgsql=/opt/postgresql \
 --with-pdo-pgsql=/opt/postgresql --enable-phpdbg \
--enable-phpdbg-webhelper --enable-phpdbg-readline --enable-sigchild \
--with-pear --with-ldap --with-ldap-sasl \
--enable-werror && make && make install
